﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button4_Click(object sender, EventArgs e)
        {
            if (double.TryParse(textBox3.Text, out double fahrenheit))
            {
                double celsius = (fahrenheit - 32) * 5.0 / 9.0;
                textBox4.Text = celsius.ToString("F2");
            }
            else
            {
                MessageBox.Show("请输入有效的华氏温度数值！");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (double.TryParse(textBox4.Text, out double celsius))
            {
                double fahrenheit = celsius * 9.0 / 5.0 + 32;
                textBox3.Text = fahrenheit.ToString("F2");
            }
            else
            {
                MessageBox.Show("请输入有效的摄氏温度数值！");
            }
        }
    }
}